<template>
  <div style="display: flex; justify-content: space-between; margin-bottom: 5px">
    <n-space>
      <n-button size="small" type="primary" @click="openAdd">
        <template #icon>
          <n-icon :component="AddCircleOutline"/>
        </template>
        新增
      </n-button>
    </n-space>

    <AddForm ref="addRef"
    />
    <UpdateForm ref="updateRef"
    />
  </div>
</template>
<script setup>
import {AddCircleOutline} from "@vicons/ionicons5";
import {NButton, NIcon, NSpace} from "naive-ui";
import AddForm from "@/views/admin/sys/user/toolbar/AddForm.vue";
import UpdateForm from "@/views/admin/sys/user/toolbar/UpdateForm.vue";

const addRef = ref();
const updateRef = ref();

const emit = defineEmits(["getDataList"]);

watch(()=>addRef?.value?.modalLoading,()=>{
  emit('getDataList')
}, {deep: true})

watch(()=>updateRef?.value?.modalLoading,(value)=>{
  value && emit('getDataList')
}, {deep: true})
const openAdd = ()=>{
  addRef.value?.onAdd()
}
const openEdit = (row,id)=>{
  updateRef.value?.onEdit(row,id);
}
defineExpose({
  openEdit
})
</script>